/**
 */
package de.claaswilke.presents.impl;

import de.claaswilke.presents.Conflict;
import de.claaswilke.presents.Person;
import de.claaswilke.presents.PresentsPackage;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Conflict</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.claaswilke.presents.impl.ConflictImpl#getConflictees <em>Conflictees</em>}</li>
 *   <li>{@link de.claaswilke.presents.impl.ConflictImpl#getConflictor <em>Conflictor</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConflictImpl extends EObjectImpl implements Conflict {
	/**
	 * The cached value of the '{@link #getConflictees() <em>Conflictees</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConflictees()
	 * @generated
	 * @ordered
	 */
	protected EList<Person> conflictees;

	/**
	 * The cached value of the '{@link #getConflictor() <em>Conflictor</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConflictor()
	 * @generated
	 * @ordered
	 */
	protected Person conflictor;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ConflictImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return PresentsPackage.Literals.CONFLICT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Person> getConflictees() {
		if (conflictees == null) {
			conflictees = new EObjectResolvingEList<Person>(Person.class, this, PresentsPackage.CONFLICT__CONFLICTEES);
		}
		return conflictees;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Person getConflictor() {
		if (conflictor != null && conflictor.eIsProxy()) {
			InternalEObject oldConflictor = (InternalEObject)conflictor;
			conflictor = (Person)eResolveProxy(oldConflictor);
			if (conflictor != oldConflictor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, PresentsPackage.CONFLICT__CONFLICTOR, oldConflictor, conflictor));
			}
		}
		return conflictor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Person basicGetConflictor() {
		return conflictor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setConflictor(Person newConflictor) {
		Person oldConflictor = conflictor;
		conflictor = newConflictor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PresentsPackage.CONFLICT__CONFLICTOR, oldConflictor, conflictor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PresentsPackage.CONFLICT__CONFLICTEES:
				return getConflictees();
			case PresentsPackage.CONFLICT__CONFLICTOR:
				if (resolve) return getConflictor();
				return basicGetConflictor();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PresentsPackage.CONFLICT__CONFLICTEES:
				getConflictees().clear();
				getConflictees().addAll((Collection<? extends Person>)newValue);
				return;
			case PresentsPackage.CONFLICT__CONFLICTOR:
				setConflictor((Person)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case PresentsPackage.CONFLICT__CONFLICTEES:
				getConflictees().clear();
				return;
			case PresentsPackage.CONFLICT__CONFLICTOR:
				setConflictor((Person)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PresentsPackage.CONFLICT__CONFLICTEES:
				return conflictees != null && !conflictees.isEmpty();
			case PresentsPackage.CONFLICT__CONFLICTOR:
				return conflictor != null;
		}
		return super.eIsSet(featureID);
	}

} //ConflictImpl
